<template>
    <div class="order">
        <div  class="title">
            <svg class="icon" aria-hidden="true" @click="goToAside()">
                <use xlink:href="#icon-cebianlanzhankai"></use>
            </svg>
            <h3>订单列表</h3>
        </div>
        <div class="order-status">
            <p v-for="(item,index) in status" :key="index" @click="moveOn(item.pass)" :class="item.pass === pass ? 'cover' : '' ">{{item.name}}</p>
        </div>
        <div class="order-list">
            <div v-for="(item, index) in filterOrder" :key="index" class="filter-order">
                <div class="order-title">
                    <h3>{{item.book_date}}</h3>
                </div>
                <div class="agency-title">
                    <p>{{item.aname}}</p>
                </div>
                <div class="agency-info">
                    <div class="agency-info-item">
                        <van-icon name="location-o" size="0.5rem"/>
                        <p class="address">{{item.local}}</p>
                    </div>
                    <div class="agency-info-item">
                        <van-icon name="phone-o" size="0.5rem"/>
                        <p>{{item.tel}}</p>
                    </div>    
                    <p class="book_time">{{item.book_time}}</p>               
                </div>
                <div class="pet-info">                   
                    <div class="pet-img">
                         <img :src="item.profile" alt="">
                    </div>
                    <div class="pet-info-item">
                        <p class="pname">{{item.pname}}</p>
                        <p>{{item.type}}</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import { getOrderDetail } from '@/api.js'
export default {
    data() {
        return {
            status:[
                {name:'待审核',pass:0},
                {name:'审核通过',pass:1},
                {name:'审核失败',pass:2}
            ],
            pass:0,
            order:[],
            filterOrder:[]
        }
    },
    created() {
        this.getOrderDetail()
    },
    methods:{
        moveOn(value) {
            this.pass = value
            let orders = this.order.filter((item) => {
                return item.pass === value
            })
            this.filterOrder = orders
            console.log(this.filterOrder)
        },
        goToAside() {
            this.$router.push('/aside')
        },
        async getOrderDetail() {
            let user = JSON.parse(localStorage.getItem('user'))
            const { data } = await getOrderDetail({user_id:user})
            this.order = data
            this.moveOn(this.pass)
        },
    }
}
</script>
<style lang="less" scoped>
.order{
    overflow: hidden;
    .title{
        position: fixed;
        background: white;
        width: 100%;
        padding:0.5rem 0.5rem 0;
        display: flex;
        align-items: center;
        .icon {
            width: 0.8rem;
        }
        h3{
            margin: 0 auto;
            font-size: 0.45rem;
        }
    }
    .order-status{
        display: flex;
        justify-content: space-around;
        align-items: center;
        margin-top: 2rem;
        height: 1rem;
        padding:0.5rem;
        p {
            padding:0.3rem;
            border-radius: 0.2rem;
        }
        .cover {
            color: white;
            background-color: #4895f2;
        }
    }
    .order-list{
        padding: 0.5rem;
        line-height: 0.8rem;
       
        .filter-order{
            border-left: 2px solid rgba(231, 132, 193, 0.671);
            margin-bottom: 0.8rem;
            padding-left: 0.3rem;
            .order-title {
                display: flex;
                justify-content: space-between;
            }
            .agency-info{
                color: #6d6868;
                margin-left: 0.5rem;
                font-size: 0.35rem;
                position: relative;
                .agency-info-item{
                    display: flex;
                    line-height: 0.5rem;
                    margin-top: 0.2rem;
                    .van-icon{
                        margin-top: 0.05rem;
                    }
                    .address{
                        width: 65%;
                    }
                }
                .book_time{
                    position: absolute;
                    right: 0;
                    top: 0;
                    border-radius: 0.15rem;
                    padding: 0.15rem;
                    line-height: 0.25rem;
                    color: rgb(235, 110, 187);
                    border:0.02rem solid rgb(235, 110, 187)
                }            
            }
            .agency-title{
                margin-left: 0.3rem;
            }
            .pet-info{
                margin: 0.3rem 0 0 0.5rem;
                display: flex;
                .pet-img{
                    border-radius: 1rem;
                    width: 1.2rem;
                    height: 1.2rem;
                    overflow: hidden;
                    text-align: center;
                    img{
                        height: 1.2rem;
                        width: auto;
                        margin-left: -0.5rem;
                    }
                }
                .pet-info-item{
                    color: #6d6868;
                    margin-left: 0.2rem;
                    font-size: 0.35rem;
                    line-height: 0.6rem;
                    .pname{
                        color: black;
                        font-size: 0.4rem;
                    }
                }
            }
        }
        
    }
}
</style>